﻿''' <summary>
''' 锐剑财务系统数据表 科目配置表
''' 对应表 - 科目配置表
''' </summary>
Public Class RjClsAcctSetupDbAccess
    Inherits ClsBaseDbAccess

    Public Sub New(ByVal s As String)
        MyBase.New(s, TABLE_NAME_RJ_ACCT_SETUP)
    End Sub

    Public Sub New(ByVal s As String, ByVal n As String)
        MyBase.New(s, n)
    End Sub

    ''' <summary>
    ''' 返回锐剑财务系统的科目配置
    ''' </summary>
    ''' <returns></returns>
    Public Function GetRjAcctSetup() As RjClsAcctSetup

        Dim tmpRetCls As RjClsAcctSetup = Nothing

        Try
            Dim tmpDb As ClsDbAccessMdb = GetConnection()
            Dim tmpList As List(Of RjClsAcctSetup)
            Dim tmpParas(0) As OleDb.OleDbParameter
            Dim tmpSql As String = "Select * from  [" & Me.AppTableName & "] "

            '打开数据库
            tmpDb.DbOpen()

            '执行
            tmpList = CType(ConvertRecordToClass(tmpDb.ExecuteSqlReturnDataSet(tmpSql, New OleDb.OleDbParameter() {})), List(Of RjClsAcctSetup))

            If tmpList IsNot Nothing Then
                tmpRetCls = tmpList(0)
            End If

            '关闭数据库
            tmpDb.DbClose()

        Catch ex As OleDb.OleDbException

            mErrorCreater = "ClsTAccountDbAccess - GetRjCwSysName"
            mErrorMessage = ex.Message
            mErrorNumber = ex.ErrorCode

        End Try

        Return tmpRetCls

    End Function

    Public Overrides Function ConvertRecordToClass(reader As OleDb.OleDbDataReader) As Object

        If reader Is Nothing Then
            Return Nothing
        End If

        Try

            Dim tmpList As List(Of RjClsAcctSetup) = New List(Of RjClsAcctSetup)
            Dim tmpCls As RjClsAcctSetup

            While reader.Read()

                tmpCls = New RjClsAcctSetup()

                With tmpCls
                    .CashCode = ConvertDbNullString(reader(0))
                    .StockCode = ConvertDbNullString(reader(1))
                    .DepCode = ConvertDbNullString(reader(2))
                    .GainCode = ConvertDbNullString(reader(3))
                    .NewAcctLen = reader.GetInt16(4) '整数是16，长整数是32
                    .OneLevelAcctLen = reader.GetInt16(5)
                    .IndustryId = reader.GetInt16(6)

                End With

                tmpList.Add(tmpCls)

            End While

            Return tmpList

        Catch ex As Exception

            mErrorNumber = -1001
            mErrorMessage = ex.Message
            mErrorCreater = "ClsTVoucherGroupDbAccess - ConvertRecordToClass"

            Return Nothing
        End Try

    End Function
End Class
